package com.sinosoft.application.schedule;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.sinosoft.application.entity.ApplicationEntity;
import com.sinosoft.application.service.ApplicationService;
import com.sinosoft.application.webservice.constant.WebServiceConstants;
import com.sinosoft.application.webservice.dto.Header;
import com.sinosoft.application.webservice.dto.Request;
import com.sinosoft.application.webservice.util.WSUtil;

/**
 * 数据同步时间调度类
 * @author leichao
 *
 */
public class SyncApplicationSchedule {
	
	@Autowired
	private ApplicationService applicationService;
	
	private Logger logger = LoggerFactory.getLogger(SyncApplicationSchedule.class);
	
	/**
	 * 时间调度函数，用于定时推送病历模板信息
	 * 1、查询未推送的病历模板信息
	 * 2、遍历单挑推送病历信息
	 * 3、更新病历模板信息的状态
	 */
	public void excute() {
		logger.debug("推送病历模板信息时间调度函数开始执行");
		/*String status = WebServiceConstants.TEMPLATE_STATUS_SUCCESS;
		List<ApplicationEntity> applications = applicationService.getApplicationByStatus(status);
		Header header = new Header("PDT_12", WebServiceConstants.RECEIVE_PLAT_ID);
		try {
			for(ApplicationEntity applicationg:applications){
				System.out.println(new Request(header, applicationg).getXmlStr());
				WSUtil.getPushOrganizationClient().acceptMessage(new Request(header, applicationg).getXmlStr());
			}
			applicationService.updateApplicationStatusById(applications, status);
		} catch (Exception e) {
			e.printStackTrace();
		}*/
		System.out.println("+++++++++++++++++++++++++++++++++++++++");
		logger.debug("推送病历模板信息时间调度函数结束");
	}
}
